#include "Base.h"
#include "MatchPlayer.h"
#include "DBProtocol.h"
#include "DBServer.h"
#include "UserManager.h"

CMatchPlayer::CMatchPlayer(void)
{
}

CMatchPlayer::~CMatchPlayer(void)
{
}

Msg* CMatchPlayer::CreateMsg(DWORD dwMsgId, int nLen)
{
	switch(dwMsgId)
	{
	case Msg_MD_Execute_SignCost:
		{
			return new MDExecuteSignCostMsg;
		}
	case Msg_MD_Load_Game_Attr:
		{
			return new MDLoadGameAttrMsg;
		}
	case Msg_MD_Match_Award_User:
		{
            return new MDMatchAwardMsg;
		}
	default:
		break;
	}
    return NULL;
}

BOOL CMatchPlayer::OnMsg(Msg *pMsg)
{
	DWORD dwMsgId = pMsg->GetMsgId();
	switch(dwMsgId)
	{
	case Msg_MD_Execute_SignCost:
		{
            return g_pUserManager->DeductSignCost(this, (MDExecuteSignCostMsg*)pMsg);
		}
	case Msg_MD_Load_Game_Attr:
		{
			return g_pUserManager->LoadGameAttr(this, (MDLoadGameAttrMsg*)pMsg);
		}
	case Msg_MD_Match_Award_User:
		{
			return g_pUserManager->AwardUser(this, (MDMatchAwardMsg*)pMsg);
		}
	default:
		break;
	}
    return TRUE;
}
